class TourDayImagesController < ApplicationController
  
  layout 'admin'

  # GET /tour_day_images
  # GET /tour_day_images.json
  def index
    @tour_day_images = TourDayImage.where('tour_day_id =?', params[:tdid])
    @tour_day_image = TourDayImage.new

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # GET /tour_day_images/1
  # GET /tour_day_images/1.json
  def show
    @tour_day_image = TourDayImage.find(params[:id])

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # GET /tour_day_images/new
  # GET /tour_day_images/new.json
  def new
    @tour_day_image = TourDayImage.new

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # GET /tour_day_images/1/edit
  def edit
    @tour_day_image = TourDayImage.find(params[:id])
  end

  # POST /tour_day_images
  # POST /tour_day_images.json
  def create
    @tour_day_image = TourDayImage.new(params[:tour_day_image])
    if @tour_day_image.save
      @tour_day_id = @tour_day_image.tour_day_id
      @data_check = true
    else
      @data_check = false
    end

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # PUT /tour_day_images/1
  # PUT /tour_day_images/1.json
  def update
    @tour_day_image = TourDayImage.find(params[:id])
    @tour_day_image.update_attributes(params[:tour_day_image])

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # DELETE /tour_day_images/1
  # DELETE /tour_day_images/1.json
  def destroy
    @tour_day_image = TourDayImage.find(params[:id])
    if @tour_day_image.destroy
      @tr_id = @tour_day_image.id
      @data_check = true
    else
      @data_check = false
    end

    respond_to do |format|
      format.js { render layout: false }
    end
  end
end
